package com.example.feign;

import feign.Feign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description:
 * @Author WuGang
 * @Date 2022/11/14 10:01
 * @Version 1.0
 */
@Controller
@RequestMapping("/feign")
public class B {

    @GetMapping("/test2")
    @ResponseBody //返回JSON必要
    public String clienttest2() {
        return "test2";
    }

    @GetMapping("/test3")
    @ResponseBody
    public String clienttest3() {
//        这里肯定有其他办法让A.class在其他服务也能用，可以不用这种方法调
        A a = Feign.builder().target(A.class, "http://127.0.0.1:8080");
//        本服务自己调自己  充当提供方和调用方
        String test = a.test0();
        return "feign调用结果" + test;
    }
}
